package club.looli.haoke.api.graphql;

import club.looli.haoke.api.service.HouseResourcesService;
import graphql.schema.DataFetchingEnvironment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * <p>
 * Created by looli on 2020/7/11
 * </p>
 *
 * <p>
 * HouseResourcesList
 * </p>
 *
 * @author looli
 * @since 2020/7/11
 */
@Component
public class HouseResourcesListDataFetcher implements MyDataFetcher{

    @Autowired
    private HouseResourcesService houseResourcesService;

    @Override
    public String fieldName() {
        return "HouseResourcesList";
    }

    @Override
    public Object dataFetcher(DataFetchingEnvironment environment) {
        Integer page = environment.getArgument("page");
        if(page == null){
            page = 1;
        }
        Integer pageSize = environment.getArgument("pageSize");
        if(pageSize == null){
            pageSize = 10;
        }
        return houseResourcesService.queryList(null,page,pageSize);
    }
}
